package com.study.config;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;


/**配置全局异常处理类
	 优先级别低于局部异常处理类
	1、添加注解@Configuration
	2、实现HandlerExceptionResolver
	3、重写resolveException方法
 * @author WuJin
 *
 */
@Configuration
public class GolbalException implements HandlerExceptionResolver {

	@Override
	public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler,
			Exception ex) {
		System.out.println("全局异常被触发.....");
		ModelAndView mv = new ModelAndView("error");
		mv.addObject("info", ex.getMessage());
		mv.addObject("msg", "全局异常处理");
		return mv;
	}

}
